package com.hippo.module.file.controller;



import com.hippo.api.file.entity.FileDataEntity;
import com.hippo.common.base.model.ResponseDataModel;
import com.hippo.common.base.util.ResponseDataUtil;
import com.hippo.module.file.service.FileDataService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;

@Controller
@RequestMapping("/fileData")
@Slf4j
public class FileDataController {
    private FileDataService fileDataService;


    @PutMapping("/updateFileDataByFileId")
    @ResponseBody
    public ResponseDataModel updateFileDataByFileId(@RequestBody FileDataEntity fileDataEntity){
        int result = this.fileDataService.updateFileDataByFileId(fileDataEntity);
        if(result>0){
            return ResponseDataUtil.createResponseData(true,"修改文件信息成功!",null);
        }

        return ResponseDataUtil.createResponseData(false,"修改文件信息失败!",null);
    }

    @PutMapping("/updateBusinessIdByBusinessId")
    @ResponseBody
    public ResponseDataModel updateBusinessIdByBusinessId(@RequestBody FileDataEntity fileDataEntity){
        int result = this.fileDataService.updateBusinessIdByBusinessId(fileDataEntity);
        if(result>0){
            return ResponseDataUtil.createResponseData(true,"修改文件信息成功!",null);
        }

        return ResponseDataUtil.createResponseData(false,"修改文件信息失败!",null);
    }


    public FileDataService getFileDataService() {
        return fileDataService;
    }

    @Autowired
    public void setFileDataService(FileDataService fileDataService) {
        this.fileDataService = fileDataService;
    }
}
